<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>trysomething</title>
	<script type="text/javascript" src="js/mummy.js" charset="utf-8"></script>
</head>

<body>
<script type="text/javascript" charset="utf-8">
console.time("Human");
Class({/*Human*/
	$define:function Human(){
		this.name = "???";
		this.father = {};
		this.mother = {};

		this.getName = function(){return this.name;}
		this.setName = function(value){this.name = value;}

		this.Human = function(pname){
			this.name = pname;
			//console.log("Constructor : "+this.getTypeName()+" param : " +name);
		}

		this.setFather = function(F){
			if($(F).Is(Man)){this.father = F;}else{throw "Man expected";}
		}

		this.getFather = function(){
			return this.father;
		}

		this.setMother = function(M){
			if($(M).Is(Woman)){this.mother = M;}else{throw "Woman expected";}
		}

		this.getMother = function(){
			return this.mother;
		}

		this.sayHello = function(){
			console.log('Hello, I am '+this.name);
		}

	}

});
console.timeEnd("Human");

console.time("Man");
Class({/*Man*/
	$extends:Human,
	$define:function Man(){
		//$(this).Extends(Human);
		this.sexe = 'male';

		this.Man=function(name){
			this.Human(name);
		}
	}

});
console.timeEnd("Man");


console.time("Woman");
Class({/*Woman*/
	$extends:Human,
	$define:function Woman(){
		//$(this).Extends(Human);
		this.sexe = 'female';

		this.Woman=function(name){
			this.Human(name);
		}
	}
});
console.timeEnd("Woman");

console.time("World");
var Humans = [], Women = [], Men = [], LIMIT = 100;//915ms pour 10000
var i=0;
Humans[i] = $(Human).New("Human N°"+i);
Women[i] = $(Woman).New("Woman N°"+i);
Men[i] = $(Man).New("Man N°"+i);
for(var i=1; i < LIMIT; i++){
	Humans[i] = $(Human).New("Human N°"+i);
	Women[i] = $(Woman).New("Woman N°"+i);
	Men[i] = $(Man).New("Man N°"+i);

	Women[i].setMother(Women[i-1]);
	Women[i].setFather(Men[i-1]);
	Men[i].setMother(Women[i-1]);
	Men[i].setFather(Men[i-1]);

}
console.timeEnd("World");
console.log(Men[80].getMother().getMother().getMother().getMother().getMother().getMother().getMother().getName());

/* 120 à 280ms*/





</script>

</body>
</html>
